#define _CRT_SECURE_NO_WARNINGS 1
#include<iostream>
// https://ac.nowcoder.com/acm/problem/15950

using namespace std;
using LL = long long;
LL n;
const int p = 1e9 + 7;

LL qpow(LL a, LL b, LL p)
{
	LL ret = 1;
	while (b)
	{
		if (b & 1)ret = (ret * a) % p;
		b >>= 1;
		a = (a * a) % p;
	}
	return ret;
}

int main()
{
	while (cin >> n)
	{
		LL a = n % p, b = (n + 1) % p, c = (2 * n + 1) % p, d = qpow(6, p - 2, p);
		LL res = (((((a * b) % p) * c) % p) * d) % p;
		cout << res << endl;
	}




	return 0;
}